/*
** Copyright (C) 2009 Joshua Brent Marsh <joshua@icub3d.com>
**  
** This file is part of icub3d-adt.
**  
** icub3d-adt is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 3 of the License, or
** (at your option) any later version.
**  
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**  
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**  
*/

/* $Id$ */

#ifndef ICUB3D_VECTOR_H
#define ICUB3D_VECTOR_H 1

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "function_prototypes.h"

typedef
struct vector
{
  void **data;
  size_t size;
  size_t max;
  size_t capacity;
} Vector;

Vector * vector_create (size_t capacity);
void vector_destroy (Vector *v, destroy_func *dest_func);


#define vector_size(v) (v)->size
#define vector_max(v) (v)->max
#define vector_capacity(v) (v)->capacity

void * vector_get (Vector *v, size_t pos);
void * vector_remove (Vector *v, size_t pos);
void * vector_put (Vector *v, size_t pos, void *item);

#define vector_remove_first(vector) vector_remove (vector, 0)
#define vector_remove_last(vector) vector_remove (vector,		\
						  vector_max (vector))
#define vector_get_first(vector) vector_get (vector, 0)
#define vector_get_last(vector) vector_get (vector, vector_max (vector))
#define vector_put_first(vector, data) vector_put (vector, 0, data)
#define vector_put_last(vector, data) vector_put (vector,		\
						  vector_max (vector),	\
						  data)
#define vector_push_back(vector, data)vector_put (vector,		 \
						  vector_max (vector)+1, \
						  data)

#endif /* ICUB3D_VECTOR_H */
